﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Text.RegularExpressions;

namespace dbcTools.Tools
{
	class loadConfig
	{
		public loadConfig()
		{
			confStore = new Dictionary<string, string>();

			if (!File.Exists("dbcTools.conf"))
				return;

			StreamReader sr = new StreamReader("dbcTools.conf", Encoding.UTF8);

			while (!sr.EndOfStream)
			{
				string line = sr.ReadLine();
				MatchCollection match = Regex.Matches(line, "^([a-zA-z0-9.]+) ?[=] ?(.*)");

				if (match.Count != 0)
					confStore.Add(match[0].Groups[1].ToString(), match[0].Groups[2].ToString());
			}
		}

		public string GetConf(string key) { return confStore.ContainsKey(key) ? confStore[key] : ""; }

		private Dictionary<string, string> confStore;

	}
}
